package priv.bruce.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import priv.bruce.service.UserService;

public class LockUserByUserIdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private UserService userService = new UserService();

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		int id = Integer.valueOf(request.getParameter("user_id"));
		try {
			if (id == 1) {
				response.getWriter().append(JSON.toJSONString(-1));
			}else {
				int banById = userService.lockUserById(id);
				System.out.println("影响行数"+banById);
				response.getWriter().append(JSON.toJSONString(banById));
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
